Skip to content

Make deleteAppDataOnUninstall configurable#88

Merged
simonhamp merged 4 commits intoNativePHP:mainfrom
igorgudelj:nsis-delete-app-data-on-uninstall
Apr 11, 2026
Merged

Make deleteAppDataOnUninstall configurable#88
simonhamp merged 4 commits intoNativePHP:mainfrom
igorgudelj:nsis-delete-app-data-on-uninstall

Conversation

@igorgudelj
Copy link
Copy Markdown
Contributor

@igorgudelj igorgudelj commented Mar 2, 2026

Summary

  • Add a nsis.delete_app_data_on_uninstall config option (defaults to false) so app developers can opt in to deleting %APPDATA%\{appName} on Windows uninstall
  • The option is passed from config/nativephp.phpBuildCommand env var → electron-builder.mjs

The underlying NSIS template already skips deletion during updates (${ifNot} ${isUpdated}), so app data is preserved when updating to a new version.

Usage

In your app's config/nativephp.php:

'nsis' => [
    'delete_app_data_on_uninstall' => true,
],

Or via environment variable: NATIVEPHP_NSIS_DELETE_APP_DATA=true

Test plan

  • Build a Windows NSIS installer with the option set to true
  • Install the app and verify app data is created in %APPDATA%
  • Uninstall the app and verify %APPDATA%\{appName} is deleted
  • Build with the option set to false (default) and verify app data persists after uninstall
  • Update the app (install over existing) and verify app data is preserved in both cases

@SRWieZ
Copy link
Copy Markdown
Member

SRWieZ commented Mar 4, 2026

Thanks for your PR. I would prefer if it was configurable. This is a breaking change otherwise.

Add a `nsis.delete_app_data_on_uninstall` option to config/nativephp.php
(defaults to false) so app developers can opt in to deleting app data on
Windows uninstall without changing the default behavior for existing
applications.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@igorgudelj igorgudelj force-pushed the nsis-delete-app-data-on-uninstall branch from ae6fe67 to 1e3f19e Compare March 4, 2026 10:09
@igorgudelj igorgudelj changed the title Delete app data on Windows uninstall Make deleteAppDataOnUninstall configurable Mar 4, 2026
@igorgudelj
Copy link
Copy Markdown
Contributor Author

Makes sense! I've updated the PR.

@simonhamp
Copy link
Copy Markdown
Member

We don't need it but it would be great if we could get a test here. We don't need to manually verify that NSIS is deleting the files, just that the flag gets passed through correctly from config to the builder script, as this would help us spot if the config value or.env key get changed by mistake.

We can safely assume that Electron Builder's options handle the values correctly given that they follow the spec in their docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@igorgudelj
Copy link
Copy Markdown
Contributor Author

I've added the tests.

@simonhamp simonhamp requested a review from a team March 16, 2026 15:23
@simonhamp simonhamp merged commit 7432405 into NativePHP:main Apr 11, 2026
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants